<template>
	<view class="my">
		<view class="info">
			<image :src="userinfo.avatar?userinfo.avatar:defaultImg" mode="" class="avatar"></image>
			<view class="info-right">
				<view class="name-info">
					<text class="name">{{userinfo.username}}</text>
					<text class="label">{{userinfo.is_vip==1?'超级管理员':''}}</text>
				</view>
				<view class="tip">
					共登录{{times}}次，上次{{time}}
				</view>
			</view>
		</view>
		<!-- 功能模块 -->
		<view class="function">
			<view class="banner ban">
				<view class="ban-title">
					<text class="dot"></text>
					<text class="titles">功能管理</text>
				</view>
				<view class="ban-list">
					<navigator url="/subPackageAdmin/UserManage/UserManage" class="item">
						<text class="iconfont icon-chengyuan green"></text>
						<text>用户管理</text>
					</navigator>
					<navigator url="/subPackageAdmin/NewsManage/NewsManage" class="item">
						<text class="iconfont icon-fapiao darkgreen"></text>
						<text>动态&介绍管理</text>
					</navigator>
					<navigator url="/subPackageAdmin/HomehelperManage/HomehelperManage" class="item">
						<text class="iconfont icon-guoqi"></text>
						<text>家政员&预约管理</text>
					</navigator>
				</view>
			</view>
			<view class="ban">
				<view class="row" @click="goEdit">
					<view >
						<text class="iconfont icon-icon_edit"></text>
						<text>编辑-关于我们</text>
					</view>
					<text class="iconfont icon-gengduo"></text>
				</view>
				<view class="row" @click="goCode">
					<view>
						<text class="iconfont icon-erweima"></text>
						<text>小程序二维码</text>
					</view>
					<text class="iconfont icon-gengduo"></text>
				</view>
			</view>
			<view class="ban">
				<view class="row" @click="goAdmin">
					<view>
						<text class="iconfont icon-wode" style="color:lawngreen"></text>
						<text>系统管理员管理</text>
					</view>
					<text class="iconfont icon-gengduo"></text>
				</view>
				<view class="row" @click="goEditPwd">
					<view>
						<text class="iconfont icon-shezhi" style="color:#20B2AA;;"></text>
						<text>修改我的管理员密码</text>
					</view>
					<text class="iconfont icon-gengduo"></text>
				</view>
			<!-- 	<view class="row" @click="goLog">
					<view>
						<text class="iconfont icon-henji"></text>
						<text>管理员操作日志</text>
					</view>
					<text class="iconfont icon-gengduo"></text>
				</view> -->
			</view>
			<view class="ban">
				<view class="row" @click="moreSetting">
					<view>
						<text class="iconfont icon-shezhi"></text>
						<text>更多设置</text>
					</view>
					<text class="iconfont icon-gengduo"></text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {GetUserinfoAdmin} from '../../api/index.js'
	export default {
		data() {
			return {
				defaultImg:'../../static/uni.png',
				userinfo:{}
			};
		},
		onLoad(options) {
			if(options.id){
				this.getUserinfoAdmin(options.id)
				this.$store.commit('addTimes',1)
				this.$store.commit('updateTime')
			}
			this.getUserinfoAdmin(1)
		},
		computed:{
			times(){
				return this.$store.state.adminLoginTimes
			},
			time(){
				return this.$store.state.adminLoginTime
			}
		},
		methods:{
			async getUserinfoAdmin(id){
				const {data:res} = await GetUserinfoAdmin(id)
				this.userinfo = res.data
				
			},
			goEdit(){
				uni.navigateTo({
					url:'/subPackageAdmin/AboutMe/AboutMe'
				})
			},
			goCode(){
				uni.navigateTo({
					url:'/subPackageAdmin/MyCode/MyCode'
				})
			},
			goAdmin(){
				uni.navigateTo({
					url:'/subPackageAdmin/AdminManage/AdminManage'
				})
			},
			goEditPwd(){
				uni.navigateTo({
					url:'/subPackageAdmin/EditPassword/EditPassword'
				})
			},
			goLog(){
				uni.navigateTo({
					url:'/subPackageAdmin/DayLog/DayLog'
				})
			},
			moreSetting(){
				let that = this
				uni.showActionSheet({
					itemList:['退出'],
					success(e) {
						if(e.tapIndex==0){
							that.userinfo ={}
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss">
.my{
	.info{
		display: flex;
		align-items: center;
		background: #1E90FF;
		padding: 30rpx 25rpx;
		color: #fff;
		.avatar{
			width: 100rpx;
			height: 100rpx;
			border-radius: 50%;
			margin-right: 25rpx;
		}
		.info-right{
			.name-info{
				.name{
					font-weight: bold;
				}
				.label{
					background: gold;
					color: orange;
					padding: 4rpx 10rpx;
					font-size: 22rpx;
					border-radius: 6rpx;
					margin-left: 12rpx;
				}
			}
			.tip{
				margin-top: 10rpx;
				font-size: 24rpx;
			}
		}
	}
	.function{
		.banner{
			.ban-title{
				display: flex;
				align-items: center;
				line-height: 60rpx;
				border-bottom: 1px solid #eee;
				padding-bottom: 10rpx;
				.dot{
					width: 10rpx;
					height: 10rpx;
					background: #888;
					border-radius: 50%;
					margin-right: 15rpx;
				}
			}
			.ban-list{
				display:flex;
				justify-content: space-evenly;
				.item{
					width: 33%;
					display: flex;
					flex-direction: column;
					align-items: center;
					padding-top: 20rpx;
					padding-bottom: 25rpx;
					border: 1px solid #eee;
					font-size: 30rpx;
					.iconfont{
						font-size: 45rpx;
						margin-bottom: 15rpx;
						
					}
					.green{
						color: lawngreen;
					}
					.icon-shoucang1{
						color: #20B2AA;
					}
				}
			}
		}
		.ban{
			background: #fff;
			margin: 20rpx auto;
			padding: 0 20rpx;
			.row{
				display: flex;
				justify-content: space-between;
				align-items: center;
				line-height: 100rpx;
				border-bottom: 1px solid #eee;
				.iconfont{
					margin-right: 12rpx;
					font-size: 40rpx;
					
				}
			}
		}
	}
}
</style>
